import { Directive, ElementRef, Renderer, HostListener } from '@angular/core';

/**
 * Generated class for the ListSearchDirective directive.
 *
 * See https://angular.io/docs/ts/latest/api/core/index/DirectiveMetadata-class.html
 * for more info on Angular Directives.
 */
@Directive({
  selector: '[list-search]'
})

export class ListSearchDirective {
  constructor(public renderer: Renderer, public elementRef: ElementRef) {
    console.log('Hello ListSearchDirective Directive');
    console.log(this);
  }

  @HostListener('click')
  onClick() { // 监听宿主元素的点击事件，设置元素背景色
    this.renderer.setElementStyle(this.elementRef.nativeElement, 
          'backgroundColor', 'red');
	}

}
